package com.whz.governance.http.ribbon.rule;

import com.whz.generic.Constants;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * @author whz
 */
@Configuration
@AutoConfigureBefore(RibbonClientConfiguration.class)
@ConditionalOnProperty(value = Constants.OPTION_RIBBON_GREY_TEST, havingValue = "true", matchIfMissing = true)
public class GreyDeployRibbonConfiguration {

    /**
     * 优先使用custom rule
     */
    @Bean
    @Scope("prototype")
    @ConditionalOnMissingBean
    public GreyDeployRule creatGreyTestRule() {
        return new GreyDeployRule();
    }
}